<?php
class keu_umk_pembayaran_model extends MY_Model {
	var $model = 'keu_umk_pembayaran';
	
	function GetJSON()
	{
		$ls_sql	= "	SELECT	UMK.ID_UMK, KAN.NAMA_KANTOR, CC.NAMA_COST_CENTER, 
							TO_CHAR(UMK.TGL_UMK, 'DD/MM/YYYY') TGL_UMK, UMK.JML_DANA_DIAJUKAN,
							UMK.KETERANGAN,
							UMK.JML_DANA_DISETUJUI,
							UMK.KD_JENIS_UMK
					FROM	KEU_UMK UMK
							INNER JOIN SW_KANTOR KAN ON KAN.KD_KANTOR = UMK.KD_KANTOR
							INNER JOIN SW_COST_CENTER CC ON CC.ID_COST_CENTER_PK = UMK.KD_COST_CENTER
					WHERE	
							NVL(UMK.STATUS_APPROVE,'P')='Y' AND
							NVL(UMK.ST_APPROVE_KEU,'P')='Y' AND
							NVL(UMK.ST_APPROVE_FINAL,'P')='Y' AND
							UMK.TGL_BAYAR IS NULL AND
							KD_JENIS_UMK IN (SELECT	KD_JENIS_UMK
											FROM	KEU_JENIS_UMK
											WHERE NVL(KD_JENIS_PINJAMAN,' ')!=' ') AND
							UMK.TGl_UMK BETWEEN 
							TO_DATE('".date_format3(post('date_from'), 'YYYY-MM-DD')."','YYYY-MM-DD') AND 
							TO_DATE('".date_format3(post('date_to'), 'YYYY-MM-DD')."','YYYY-MM-DD') AND					
							(
								UPPER(UMK.ID_UMK) LIKE UPPER('%".post('keyword')."%') OR
								UPPER(KAN.NAMA_KANTOR) LIKE UPPER('%".post('keyword')."%') OR
								UPPER(CC.NAMA_COST_CENTER) LIKE UPPER('%".post('keyword')."%') OR
								UPPER(UMK.KETERANGAN) LIKE UPPER('%".post('keyword')."%')	
							)
					ORDER BY ".(post('sort')=='' ? 'UMK.ID_UMK' : post('sort'))." ".(post('order')=='' ? 'ASC' : post('order'));
					
		return json_encode( $this->paging($ls_sql) );
	}
	
	function Add($arr_data){
		$this->db->insert('KEU_TRANS_KAS_BANK', $arr_data);
	}
	
}
?>